import type { Directive, DirectiveBinding } from 'vue';

export const permission: Directive = {
  mounted(el: HTMLElement, binding: DirectiveBinding<string | Array<string>>) {
    const { value } = binding;
    if (value) {
      //权限处理
      // eslint-disable-next-line @typescript-eslint/no-unused-expressions
      el.parentNode && el.parentNode.removeChild(el);
    } else {
      throw new Error("[Directive: permission]: need perms! Like v-permission=\"['menu.add','menu.edit']\"");
    }
  },
};
